package Sort2;

import java.util.Arrays;

public class Insert {
    public static void main(String[] args) {
        int[] arr={5,9,8,1,1,5,4};
        insert(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void insert(int[] arr){
        for(int bound=1;bound<arr.length;bound++){
            int temp=arr[bound];
            int cur=bound-1;
            for(;cur>=0;cur--){
                if(arr[cur]>temp){
                    arr[cur+1]=arr[cur];
                }else{
                    break;
                }
            }
            arr[cur+1]=temp;
        }
    }
}
